var eventproxy=require('eventproxy');
var ep=new eventproxy();

function mockGet(cb){
    setTimeout(function () {
        console.log('网络请求...');
        cb(null,'网络请求');
    },Math.random()*1000|0);
}

function mockRead(cb){
    setTimeout(function () {
        console.log('读取文件...');
        cb(null,'读取文件');
    },Math.random()*1000|0);
}

function mockQuery(cb){
    setTimeout(function () {
        console.log('查询数据库...');
        cb(null,'查询数据库');
    },Math.random()*1000|0);
}


//--------------------------------

ep.on('read', function (data) {
    console.log('read:',data);
});

var cnt=0;
setInterval(function () {
    mockRead(function (err, data) {
        ep.emit('read',data);
        if(cnt++>3){
            ep.removeListener('read');
        }
    });
},2000);



